import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class test02 {
    @Test
    public void testGetBean(){
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        User u1 = applicationContext.getBean("user1",User.class);
        User u2 = applicationContext.getBean("user2",User.class);
        User u3 = applicationContext.getBean("user3",User.class);
        User u4 = applicationContext.getBean("user4",User.class);
        User u5 = applicationContext.getBean("user5",User.class);
        User u6 = applicationContext.getBean("user6",User.class);
        System.out.println(u1);
        System.out.println(u2);
        System.out.println(u3);
        System.out.println(u4);
        System.out.println(u5);
        System.out.println(u6);
    }

    @Test
    public  void testSTLBean(){
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        Student stu = applicationContext.getBean("student1",Student.class);
        System.out.println("stu = "+stu);
        Book book = applicationContext.getBean("bookfactory",Book.class);
        System.out.println(book);
    }

}
